home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 June / EnigmA AMIGA RUN 08 (1996)(G.R. Edizioni)(IT)[!][issue 1996-06][EARSAN CD VII].iso / earcd / arexx / ww5clndr.lha / Calendar.rexx < prev   
OS/2 REXX Batch file  |  1996-04-20  |  4KB  |  176 lines

  1. /*********************************************/
  2. /*                                           */
  3. /*               Calendar v1.0               */
  4. /*      An AREXX script for Wordworth 5      */
  5. /* By Adam Dawes (Adam@beachyhd.demon.co.uk) */
  6. /*              19th April 1996              */
  7. /*                                           */
  8. /*********************************************/
  9.  
  10.  
  11.     Options Results
  12.  
  13. /*-- First find the month we're supposed to draw --*/
  14.  
  15.     calmonthname = ""
  16.     calyear = ""
  17. GetMonth:
  18.     WizardReq TITLE "Calendar v1.0 by Adam Dawes" LABEL "Select month and year for calendar:" TEXTBOX 1 "_Month:" CONTENTS calmonthname TEXTBOX 2 "_Year:" CONTENTS calyear BUTTON 1 "_OK" BUTTON 2 "_This Month" BUTTON "-1" "_Cancel"
  19.     Pressed = Result
  20.     if Pressed = -1 then exit sub
  21.     
  22.     if Pressed = 2 then do
  23.         calmonthname = Date("M")
  24.         calyear = left(Date("S"),4)
  25.         signal GetMonth
  26.     end
  27.  
  28.     Wizard_GetTextBox 1
  29.     calmonthname = Result
  30.     Wizard_GetTextBox 2
  31.     calyear = Result
  32.  
  33.  
  34. /*-- Now check we have a valid month and year --*/
  35.  
  36.  
  37.     if calyear < 0 then do
  38.         RequestNotify "Invalid year: "calyear
  39.         signal GetMonth
  40.     end
  41.  
  42.     if calyear <100 then calyear = calyear + 1900
  43.  
  44.  
  45.     if length(calmonthname) > 0 then do        /* convert to correct case: Xxxx... */
  46.         calmonthname = translate(calmonthname,"abcdefghijklmnopqrstuvwxyz","ABCDEFGHIJKLMNOPQRSTUVWXYZ")
  47.         calmonthname = upper(left(calmonthname,1))||right(calmonthname,length(calmonthname)-1)
  48.     end
  49.  
  50.     calmonth = 0
  51.     do monthcheck = 1 to 12
  52.         monthtemp = monthcheck
  53.         if monthtemp < 10 then monthtemp = "0"monthtemp
  54.         if calmonthname = date("M","1996"monthtemp"01","S") | calmonthname = left(date("M","1996"monthtemp"01","S"),3) then calmonth = monthcheck
  55.     end
  56.     if calmonth < 10 then calmonth = "0"calmonth
  57.  
  58.  
  59.     if calmonth = 0 then do
  60.         RequestNotify "Unrecognised month: "calmonthname
  61.         signal GetMonth
  62.     end
  63.  
  64.     
  65. /*-- Find the first and last date to be drawn on the calendar --*/
  66.  
  67.     startdate = date("I",calyear||calmonth||01,"S")
  68.     startweekday = date("W",calyear||calmonth||01,"S")
  69.  
  70.     calendartitle = date("M",startdate)" "calyear
  71.  
  72.     calmonth = calmonth + 1
  73.     if calmonth = 13 then do
  74.         calmonth = 1
  75.         calyear = calyear + 1
  76.     end
  77.     if calmonth < 10 then calmonth = "0"calmonth
  78.  
  79.     enddate = date("I",calyear||calmonth||01,"S")
  80.  
  81.     do daycheck = 0 to 6
  82.         daytemp = "0"daycheck+1
  83.         if startweekday = date("W","199604"daytemp,"S") then currday = daycheck
  84.     end
  85.  
  86. /*    if startweekday = "Monday" then currday = 0
  87.     if startweekday = "Tuesday" then currday = 1
  88.     if startweekday = "Wednesday" then currday = 2
  89.     if startweekday = "Thursday" then currday = 3
  90.     if startweekday = "Friday" then currday = 4
  91.     if startweekday = "Saturday" then currday = 5
  92.     if startweekday = "Sunday" then currday = 6
  93. */
  94.  
  95. /*-- Now start drawing the calendar --*/
  96.  
  97.     DrawTextFrame 1 "4cm" "2cm" "7cm" "1cm" "0.0cm" "0.0cm" "0cm" "0cm" TRANSPARENT
  98.     monthid = Result
  99.     SelectObject monthid
  100.     NewParagraph
  101.     Cursor UP
  102.     CentreJustify
  103.     Font NAME "Shannon Book" SIZE "12"
  104.     Text calendartitle
  105.  
  106.  
  107. /*-- Draw the day headers --*/
  108.  
  109.     do i = 0 to 6
  110.         DrawTextFrame 1 i+4"cm" "3cm" "1cm" "0.8cm" "0.0cm" "0.0cm" "0cm" "0cm" TRANSPARENT
  111.         titleid.i = Result
  112.         SelectObject titleid.i
  113.  
  114.         NewParagraph
  115.         Cursor UP
  116.         CentreJustify
  117.         Font NAME "Shannon Book" SIZE "9"
  118.         if i = 0 then Text "Mon"
  119.         if i = 1 then Text "Tue"
  120.         if i = 2 then Text "Wed"
  121.         if i = 3 then Text "Thu"
  122.         if i = 4 then Text "Fri"
  123.         if i = 5 then Text "Sat"
  124.         if i = 6 then Text "Sun"
  125.     end
  126.  
  127.  
  128. /*-- Draw the actual days --*/
  129.  
  130.     currdate = startdate
  131.     dayval = 1
  132.     ypos = 3.8
  133.  
  134.     do while currdate < enddate
  135.         DrawTextFrame 1 currday+4"cm" ypos"cm" "1cm" "0.6cm" "0.1cm" "0.1cm" "0cm" "0cm" TRANSPARENT
  136.         frameid.dayval = Result
  137.         SelectObject frameid.dayval
  138.  
  139.         NewParagraph
  140.         Cursor UP
  141.         CentreJustify
  142.         Font NAME "Shannon Book" SIZE "11"
  143.         Text dayval
  144.  
  145.         currdate = currdate + 1
  146.         dayval = dayval + 1
  147.         currday = currday + 1
  148.         if currday = 7 then do
  149.             currday = 0
  150.             ypos = ypos + 0.6
  151.         end
  152.     end
  153.  
  154.  
  155.  
  156. /*-- Select all the objects we've created, and group them to a single object --*/
  157.  
  158.     SelectObject monthid
  159.  
  160.     do i = 0 to 6
  161.         SelectObject titleid.i MULTISELECT
  162.     end
  163.  
  164.     currdate = startdate
  165.     dayval = 1
  166.     do while currdate < enddate
  167.         SelectObject frameid.dayval MULTISELECT
  168.         dayval = dayval + 1
  169.         currdate = currdate + 1
  170.     end
  171.  
  172.     Group
  173.  
  174.  
  175. /*-- Finished --*/
  176.